import CryptoJS from 'crypto-js'

const key = CryptoJS.enc.Utf8.parse('Gf2HwQHmkPMiHCPI') // 十六位十六进制数作为密钥
const iv = CryptoJS.enc.Utf8.parse('S017sO8V3y4hATfm') //十六位十六进制数作为密钥偏移量

export function aesDecrypt(word) {
  const decrypt = CryptoJS.AES.decrypt(word, key, {
    iv,
    mode: CryptoJS.mode.CBC,
    padding: CryptoJS.pad.Pkcs7
  })
  return decrypt.toString(CryptoJS.enc.Utf8)
}

export function aesEncrypt(word) {
  let encrypted = CryptoJS.AES.encrypt(word, key, {
    iv: iv,
    mode: CryptoJS.mode.CBC,
    padding: CryptoJS.pad.Pkcs7
  })
  return encrypted.toString()
}
